import { createSlice } from '@reduxjs/toolkit'

const initialState={
    value:0,
}
//创建一个切片Slice
export const counterSlice=createSlice({
    name:'counter',
    initialState,
    reducers:{
        //定义一个加的方法
        increment:(state)=>{
            state.value++
        },
        //定义一个减的方法
        decrement:(state)=>{
            state.value--
        },
    },
})
console.log('counterSlice',counterSlice)
console.log('counterSlice.actions',counterSlice.actions)


//导出加减方法
export const { increment, decrement }=counterSlice.actions
//暴露reducer
export default counterSlice.reducer;